package com.tbit.uqbike.object.pojo.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tbit.uqbike.constant.enums.FaceCheckTypeEnum;
import lombok.*;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.Objects;

/**
 * @author yee_
 * @version 1.0
 * @date 2023/5/5 15:34
 */
@Getter
@Setter
@Accessors(chain = true)
@ToString
@TableName(value = "userfacedata")
public class UserFaceDataVO {
    @TableId(type = IdType.AUTO)
    private Integer faceId;
    private Integer accountId;
    private Integer userId;
    @TableField(exist = false)
    private String phone;
    private String url;
    private Date addTime;
    private Double similarity;
    private String remark;

    /**
     * 统一相似度格式
     */
    public void formatSimilar(){
        if (Objects.isNull(similarity)){
            similarity = 0d;
        }
        // 1 - 100
        if (similarity <= 100 && similarity > 1){
            similarity = similarity / 100;
        }
        // 100 - 1000
        if (similarity > 100){
            similarity = similarity / 1000;
        }
        similarity = new BigDecimal(similarity).setScale(2, RoundingMode.HALF_UP).doubleValue();
    }
}
